package in.muton.edushare.pages.coursepages;

import in.muton.edushare.pages.deptpages.DeptPage;
import in.muton.edushare.processing.objects.CourseDataHandler;
import in.muton.edushare.url.EntityPageParams;
import in.muton.edushare.wicket.models.CayenneList;
import in.muton.panels.paginator.EntityListing;

import org.apache.wicket.PageParameters;
import org.apache.wicket.RestartResponseAtInterceptPageException;

import com.edushare.common.constants.ApplicationConstants;
import com.edushare.common.vo.Departments;

public class CourseDept extends CourseBase {

	public CourseDept(PageParameters params) {
		super(params);
		CayenneList<Departments> cL = new CourseDataHandler(getCourseInstance())
				.getDept();
		if (cL.getObject().size() == 1) {
			DeptPage p = new DeptPage(EntityPageParams.getParams(cL.getObject()
					.get(0)));
			throw new RestartResponseAtInterceptPageException(p);
		}
		
		add(new EntityListing<Departments>("thumbList", cL, this));
	}

	@Override
	protected String getActivePage(PageParameters params) {
		return "courseDept";
	}

	@Override
	public String getPageTitle() {
		return getLoggedInUser().getCompleteUserName() + " | "
		+ getCourse().getObject().getCourseName()
		+ " | Departments | "
		+ ApplicationConstants.APPLICATION_NAME;		
	}

}
